﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace 第六章
{
    public partial class _6__3_ResultForm : System.Web.UI.Page
    {
        int count = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies.Get("count");
            HttpCookie myCookie = null;
            if (Request.Cookies["Name"] == null)
            {
                Response.Redirect("~/6.3.aspx");
            }
            else
            {
                if (cookie != null)
                {
                    if (cookie.Name.Equals("count"))
                    {
                        myCookie = cookie;
                    }
                }
                if (myCookie != null)
                {
                    count = Convert.ToInt32(myCookie.Value);
                    count++;
                    myCookie.Value = count.ToString();
                    Response.AppendCookie(myCookie);
                    Response.Write(String.Format("{0}是第{1}次访问",Request.Cookies["Name"].Value,count));
                }
                else
                {
                    myCookie = new HttpCookie("count","1");
                    Response.AppendCookie(myCookie);
                    Response.Write(String.Format("{0}是第{1}次访问", Request.Cookies["Name"].Value, myCookie.Value));
                }
            }
        }
    }
}